<template>
  <div :class="{ head: true, bg: bgc == 1 }">
    <i class="el-icon-s-operation"></i>
    <div class="content" v-show="title != ''">
      <p>{{ title }}</p>
    </div>
    <div>
      <div v-show="mes == ''">
        <input v-model="text" type="text" placeholder="请输入你想搜索的内容" />
      </div>
      <i @click="xiugai" v-show="rig != ''" :class="rig"></i>
    </div>
  </div>
</template>
<script>
export default {
  name: "Head",
  props: ["mes", "rig", "title", "bgc"],
  data() {
    return {
      text: "",
    };
  },
  methods: {
    xiugai() {
      if (this.rig == "el-icon-search") {
        if (this.text == "") {
          return alert("搜索内容不能为空");
        }
        this.$store.commit("gai", this.text);
        this.$router.push({ name: "Sousuo" });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.head {
  width: 100%;
  height: 60px;
  //   background-color: aqua;
  position: sticky;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  > i {
    margin-left: 15px;
    font-size: 30px;
  }
  > div {
    // background-color: chartreuse;
    display: flex;
    align-items: center;
    // margin: auto;
    > div {
      width: 250px;
      height: 40px;
      background-color: rgb(240, 240, 240);
      border-radius: 40px;
      display: flex;
      align-items: center;
      padding-left: 15px;

      > input {
        // line-height: 40px;
        width: 200px;
        height: 30px;
        border: none;
        outline: none;
        background-color: rgba(0, 0, 0, 0);
      }
    }
    > i {
      font-size: 25px;
      margin-left: 10px;
      margin-right: 10px;
    }
  }
}
.content {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: auto;
  font-size: 22px;
  // background-color: white;
}
.bg {
  background-color: white;
}
</style>